package com.athuiju.hr.controller;


import com.athuiju.commonutils.R;
import com.athuiju.hr.entity.Organization;
import com.athuiju.hr.service.OrganizationService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wzh
 * @since 2021-12-15
 */
@RestController
@Api(value="组织列表controller",tags={"员工组织列表操作接口"})
@RequestMapping("/hr/organization")
public class OrganizationController {
    @Autowired
    private OrganizationService organizationService;

    @ApiOperation(value = "所有组织列表")
    @GetMapping("list")
    @ApiResponses({@ApiResponse(code = 200,message = "OK",response = Organization.class),
    })
    public R list(){
        List<Organization> organizationList=organizationService.list(null);
        return R.ok().data("organizationList",organizationList);
    }






    @ApiOperation(value = "根据id查询组织信息")
    @GetMapping("getOrganizationInfo/{organizationid}")
    @ApiResponses({@ApiResponse(code = 200,message = "OK",response = Organization.class),
    })
    public R getOrganizationInfo(@ApiParam(name = "organizationid",value = "组织id",required = true)
                          @PathVariable String organizationid){
        Organization organization=organizationService.getById(organizationid);
        return  R.ok().data("organization",organization);
    }


}

